package zy;

import zy.dongwu;

class dongwu {
	protected String name;
	protected int x;
	protected int y;
	protected int r;

	public void show() {
		System.out.println(name + "的初始位置为[" + this.x + "," + this.y + "]");
	}

	public dongwu(String name, int x, int y, int r) {
		this.name = name;
		this.x = x;
		this.y = y;
		this.r = r;
	}

	public String eat() {
		String str = "x:" + this.x + "y:" + this.y;
		return str;
	}

	public void move() {

		int A = 20, B = 1;
		int a = 30, b = 50;
		int ran1 = (int) (Math.random() * (A - B) + B);
		int ran2 = (int) (Math.random() * (a - b) + b);

		if (ran1 >= 0 && ran1 <= 10 && ran2 >= 30 && ran2 <= 40) {
			this.x = this.x + this.r;
			System.out.println(name + "当前坐标[" + this.x + "," + this.y + "]");
		} else {
			System.out.println(name + "当前坐标[" + this.x + "," + this.y + "]");
		}
		if (ran1 >= 10 && ran1 <= 20 && ran2 >= 40 && ran2 <= 50) {
			this.y = this.y + this.r;
			System.out.println(name + "当前坐标[" + this.x + "," + this.y + "]");
		} else {
			System.out.println(name + "当前坐标[" + this.x + "," + this.y + "]");
		}
	}
}

class Tiger extends dongwu {

	public Tiger(String name, int x, int y, int r) {
		super(name, x, y, r);
	}
}

class Wolf extends dongwu {
	public Wolf(String name, int x, int y, int r) {
		super(name, x, y, r);
	}
}

class Sheep extends dongwu {
	public Sheep(String name, int x, int y, int r) {
		super(name, x, y, r);
	}
}